require(["config"],function(){
	require(["jquery","header"],function($){
		function Register(){
			this.addListener();
		}
		$.extend(Register.prototype,{
			addListener:function(){
				$(".register-btn").on("click",$.proxy(this.registerHandler,this));
			},
			registerHandler:function(){
				var data = $("form").serialize();
				var url = "http://localhost/api/register.php";
				$.post(url,data,this.regSuccessHandler,"json");
				return false;
			},
			regSuccessHandler:function(data){
				if(data.res_code===1){
					location = "/html/login.html";
				}else{
					$(".reg-tip").show().text("注册失败！请重试");
				}
			}
		});
		new Register();
	});
});